package com.icemelon.catdog.service;

import com.icemelon.catdog.dao.FriendMapper;
import com.icemelon.catdog.dao.UserMapper;
import com.icemelon.catdog.pojo.Friend;
import com.icemelon.catdog.pojo.User;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.Arrays;
import java.util.List;
@Service
public class UserFanServiceImpl implements UserFanService {

    @Autowired
    FriendMapper friendMapper;

    @Autowired
    UserMapper userMapper;

    @Transactional
    @Override
    public void delectFanUsers(Integer[] ids) {
        List<Integer> idList= Arrays.asList(ids);
        friendMapper.deleteBatchIds(idList);
    }

    @Override
    public List<User> getFanUser(Integer id) {
        List<Integer> fansId = friendMapper.findFriendById(id);
        List<User> fans = userMapper.selectBatchIds(fansId);
        return fans;
    }

}
